﻿namespace ClassyBlog.Infrastructure.Specs.Unit
{
    using System;
    using System.Collections.Generic;

    using Machine.Specifications;

    [Subject(typeof(Formatter))]
    public class when_creating_formatter_with_null_supported_types
    {
        static Exception exception;

        Because of = () => exception = Catch.Exception(() =>
            new FormatterTestDouble(null));

        It should_throw_exception = () =>
            exception.ShouldBeOfType<ArgumentNullException>();
    }

    [Subject(typeof(Formatter))]
    public class when_matching_type_exists
    {
        static Formatter formatter;
        static bool supported;

        Establish context = () =>
            formatter = new FormatterTestDouble(new[]
                                                    {
                                                        "txt"
                                                    });

        Because of = () => supported = formatter.Supports("txt");

        It should_be_supported = () => supported.ShouldBeTrue();
    }

    public class FormatterTestDouble : Formatter
    {
        public FormatterTestDouble(IEnumerable<string> supportedTypes) :
            base(supportedTypes)
        {
        }

        public override string Format(string value)
        {
            throw new NotImplementedException();
        }
    }
}